package com.qs.model.enums;

/**
 * ClassName: PayInfo
 * Package: com.qs.model.enums
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2024/3/30 - 15:32
 * @Version: v1.0
 */

import com.alibaba.fastjson.annotation.JSONType;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.databind.deser.std.EnumDeserializer;
import com.fasterxml.jackson.databind.ser.std.EnumSerializer;
import lombok.Getter;

/**
 * 对应订单的状态0：待发货；1：待收货；2：已收货
 */
@JSONType(serializer = EnumSerializer.class, deserializer = EnumDeserializer.class, serializeEnumAsJavaBean = true)
@Getter
public enum OrderEnum {
    WAIT_DELIVER(0,"待发货"),
    WAIT_RECEIVE(1,"待收货" ),
    HAVE_RECEIVE(2,"已收货" );

    @EnumValue
    private Integer code ;
    private String comment ;

    /**
     * 构造
     * @param code
     * @param comment
     */
    OrderEnum(Integer code, String comment ){
        this.code=code;
        this.comment=comment;
    }

    /**
     * 遍历
     */

    public static OrderEnum getComment(Integer code){
        for (OrderEnum payInfoEnum : OrderEnum.values()) {
            if(code.intValue() == payInfoEnum.getCode()){
                return payInfoEnum;
            }
        }
        return null;
    }
}
